package cn.kgc.javaweb.listener;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
 * @author: mosin
 * @version: v1.0  2022/5/31
 * 监听器 监听session对象的创建和销毁过程
 */
@WebListener
public class MySessionListener implements HttpSessionListener {

    //session的创建
    @Override
    public void sessionCreated(HttpSessionEvent se) {
        System.out.println("session对象被创建:sessionID= "+se.getSession().getId());
    }

    //session的销毁
    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        System.out.println("session对象被销毁:sessionID="+se.getSession().getId());
    }
}
